package models

import (
	orm "go-papers/database"
	_ "time"
)

type OrderReturnLog struct {
	Id            int     `json:"id" gorm:"type:int(11) unsigned;primary_key"` //
	OrderId       int     `json:"orderId" gorm:"type:int(11);"`                // 订单id
	OrderPrice    float64 `json:"orderPrice" gorm:"type:decimal(10,2);"`       // 订单有效金额 --refundPrice float64
	ReturnPrice   float64 `json:"returnPrice" gorm:"type:decimal(10,2);"`      // 订单有效金额 --refundPrice float64
	ReturnAccount string  `json:"returnAccount" gorm:"type:varchar(255);"`     // 回退账户
	ReturnNo      string  `json:"returnNo" gorm:"type:varchar(255);"`          // 回退单号
	ReturnStatus  string  `json:"returnStatus" gorm:"type:varchar(32);"`       // 状态
	ReturnInfo    string  `json:"returnInfo" gorm:"type:varchar(255);"`        // 请求信息
	BackInfo      string  `json:"backInfo" gorm:"type:varchar(255);"`          // 返回信息

	DataScope string `json:"dataScope" gorm:"-"`
	Params    string `json:"params"  gorm:"-"`
	BaseModel
}

func (OrderReturnLog) TableName() string {
	return "order_return_log"
}

// 创建OrderRefund
func (e *OrderReturnLog) Create() (OrderReturnLog, error) {
	var doc OrderReturnLog
	result := orm.Eloquent.Table(e.TableName()).Create(&e)
	if result.Error != nil {
		err := result.Error
		return doc, err
	}
	doc = *e
	return doc, nil
}
